﻿<src:OverlayWindow x:Class="GW2PAO.Views.WvWTracker.WvWTrackerView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:src="clr-namespace:GW2PAO.Views"
        xmlns:view="clr-namespace:GW2PAO.Views.WvWTracker"
        xmlns:converters="clr-namespace:GW2PAO.Style.Converters"
        xmlns:core="clr-namespace:GW2PAO.PresentationCore;assembly=GW2PAO.PresentationCore"
        xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        WindowStyle="None" AllowsTransparency="true" Background="Transparent"
        ResizeMode="NoResize"
        Topmost="True"
        Closed="Window_Closed"
        TextOptions.TextFormattingMode="Display">

    <src:OverlayWindow.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Style/ResourceLibrary.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <BooleanToVisibilityConverter x:Key="BoolToVisibility" />
            <converters:WvWMapConverter x:Key="MapConverter" />

            <core:AutoRefreshCollectionViewSource Source="{Binding Objectives}" x:Key="ObjectivesCollection">
                <CollectionViewSource.SortDescriptions>
                    <scm:SortDescription PropertyName="Type" />
                </CollectionViewSource.SortDescriptions>
            </core:AutoRefreshCollectionViewSource>

        </ResourceDictionary>
    </src:OverlayWindow.Resources>

    <Grid>

        <Grid.Effect>
            <DropShadowEffect Color="Black" BlurRadius="10" Opacity="0.5" Direction="0" ShadowDepth="0" />
        </Grid.Effect>

        <Grid.Background>
            <RadialGradientBrush Opacity="0.5" Center="0,0" GradientOrigin="0,0" RadiusX="1" RadiusY="1">
                <GradientStop Color="#FF5B4411" Offset="0"/>
                <GradientStop Color="#005B4411" Offset="1"/>
            </RadialGradientBrush>
        </Grid.Background>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Border Name="TitleBar" Style="{StaticResource TitleBarStyle}"
                MouseLeftButtonDown="TitleBar_MouseLeftButtonDown"
                Grid.Row="0">
            <Grid Margin="5,0,0,0">

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="30" />
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="35" />
                    <ColumnDefinition Width="35" />
                </Grid.ColumnDefinitions>

                <Image Name="TitleImage"
                       Grid.Column="0"
                       VerticalAlignment="Center"
                       Height="30" Width="30"
                       Margin="0,0,0,0"
                       Source="/Resources/WorldvsWorld.png"
                       MouseDown="TitleImage_MouseDown">
                    <Image.ContextMenu>
                        <ContextMenu>
                            <MenuItem Header="Orientation">
                                <MenuItem Header="Vertical" IsCheckable="True" IsChecked="{Binding IsVerticalOrientation}" />
                                <MenuItem Header="Horizontal" IsCheckable="True" IsChecked="{Binding IsHorizontalOrientation}" />
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="Show Est. Time-Distances" IsCheckable="True" IsChecked="{Binding UserSettings.AreTimeDistancesShown}" />
                            <MenuItem Header="Distance Units">
                                <MenuItem Header="Feet" IsCheckable="True" IsChecked="{Binding IsFeetSelected}" />
                                <MenuItem Header="Meters" IsCheckable="True" IsChecked="{Binding IsMetersSelected}" />
                                <MenuItem Header="Time-Distances" IsCheckable="True" IsChecked="{Binding IsTimeDistanceSelected}" />
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="Reset Hidden Objectives" Command="{Binding ResetHiddenObjectivesCommand}" />
                            <MenuItem Header="Show">
                                <MenuItem Header="Red Objectives" IsCheckable="True" IsChecked="{Binding UserSettings.AreRedObjectivesShown}" />
                                <MenuItem Header="Green Objectives" IsCheckable="True" IsChecked="{Binding UserSettings.AreGreenObjectivesShown}" />
                                <MenuItem Header="Blue Objectives" IsCheckable="True" IsChecked="{Binding UserSettings.AreBlueObjectivesShown}" />
                                <MenuItem Header="Neutral Objectives" IsCheckable="True" IsChecked="{Binding UserSettings.AreNeutralObjectivesShown}" />
                                <Separator />
                                <MenuItem Header="Castles" IsCheckable="True" IsChecked="{Binding UserSettings.AreCastlesShown}" />
                                <MenuItem Header="Keeps" IsCheckable="True" IsChecked="{Binding UserSettings.AreKeepsShown}" />
                                <MenuItem Header="Towers" IsCheckable="True" IsChecked="{Binding UserSettings.AreTowersShown}" />
                                <MenuItem Header="Camps" IsCheckable="True" IsChecked="{Binding UserSettings.AreCampsShown}" />
                                <MenuItem Header="Bloodlust Objectives" IsCheckable="True" IsChecked="{Binding UserSettings.AreBloodlustObjectivesShown}" />
                            </MenuItem>
                            <MenuItem Header="Names">
                                <MenuItem Header="Cardinal Directions" IsCheckable="True" IsChecked="{Binding IsCardinalDirectionsSelected}" />
                                <MenuItem Header="Short Names" IsCheckable="True" IsChecked="{Binding IsShortNamesSelected}" />
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="Use Player's Map" IsCheckable="True" IsChecked="{Binding IsUsingPlayerMap}" />
                            <MenuItem Header="Override Displayed Map">
                                <MenuItem Header="Red Borderlands" IsCheckable="True" IsChecked="{Binding IsUsingRedBorderlands}" />
                                <MenuItem Header="Green Borderlands" IsCheckable="True" IsChecked="{Binding IsUsingGreenBorderlands}" />
                                <MenuItem Header="Blue Borderlands" IsCheckable="True" IsChecked="{Binding IsUsingBlueBorderlands}" />
                                <MenuItem Header="Eternal Battlegrounds" IsCheckable="True" IsChecked="{Binding IsUsingEternalBattlegrounds}" />
                            </MenuItem>
                            <Separator />
                            <MenuItem Header="Close" Click="CloseWindowButton_Click" />
                        </ContextMenu>
                    </Image.ContextMenu>
                    <Image.Style>
                        <Style TargetType="{x:Type Image}">
                            <Setter Property="Effect">
                                <Setter.Value>
                                    <DropShadowEffect ShadowDepth="0"
                                              Color="Goldenrod"
                                              Opacity="0"
                                              BlurRadius="25"/>
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <Trigger Property="IsMouseOver" Value="True">
                                    <Trigger.EnterActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="1"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:00.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.EnterActions>
                                    <Trigger.ExitActions>
                                        <BeginStoryboard>
                                            <Storyboard>
                                                <DoubleAnimation To="0"
                                                         Storyboard.TargetProperty="(Effect).Opacity"
                                                         Duration="00:00:0.1"/>
                                            </Storyboard>
                                        </BeginStoryboard>
                                    </Trigger.ExitActions>
                                </Trigger>
                            </Style.Triggers>
                        </Style>
                    </Image.Style>
                </Image>

                <core:OutlinedTextBlock Grid.Column="1" Margin="5,0,0,0"
                                        HorizontalAlignment="Left" VerticalAlignment="Center" 
                                        Fill="Orange" FontFamily="Candara" FontSize="12"
                                        Text="{Binding WvWMapVM.Map, Converter={StaticResource MapConverter}}" />

                <Button Name="CollapseExpandButton"
                    Grid.Column="2"
                    Margin="5"
                    Click="CollapseExpandButton_Click">
                    <Button.Style>
                        <Style TargetType="Button" BasedOn="{StaticResource TitleBarButtonStyle}">
                            <Setter Property="Content" Value="{StaticResource CollapseGraphic}" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Visibility, ElementName=ObjectivesContainer}" Value="Collapsed">
                                    <DataTrigger.Setters>
                                        <Setter Property="Content" Value="{StaticResource ExpandGraphic}" />
                                    </DataTrigger.Setters>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Button.Style>
                </Button>

                <Button Name="CloseWindowButton"
                    Grid.Column="3"
                    Margin="5"
                    Style="{StaticResource TitleBarButtonStyle}"
                    Content="{StaticResource CloseGraphic}"
                    Click="CloseWindowButton_Click" />
            </Grid>
        </Border>

        <Grid Name="ObjectivesContainer" Grid.Row="1">
            <ScrollViewer Style="{StaticResource LeftScrollViewer}"
                          HorizontalScrollBarVisibility="Auto"
                          VerticalScrollBarVisibility="Auto"
                          PreviewMouseWheel="ScrollViewer_PreviewMouseWheel">
                <StackPanel>
                    <ItemsControl Name="ObjectivesControl"
                                  ItemsSource="{Binding Source={StaticResource ObjectivesCollection}}"
                                  Margin="0,0,0,5" HorizontalAlignment="Left" VerticalAlignment="Top">
                        <ItemsControl.Style>
                            <Style TargetType="ItemsControl">
                                <Setter Property="Template">
                                    <Setter.Value>
                                        <ControlTemplate>
                                            <Border>
                                                <StackPanel IsItemsHost="True">
                                                    <StackPanel.Style>
                                                        <Style TargetType="StackPanel">
                                                            <Setter Property="Orientation" Value="Vertical" />
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding UserSettings.IsTrackerHorizontal}" Value="True">
                                                                    <DataTrigger.Setters>
                                                                        <Setter Property="Orientation" Value="Horizontal" />
                                                                    </DataTrigger.Setters>
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </StackPanel.Style>
                                                </StackPanel>
                                            </Border>
                                        </ControlTemplate>
                                    </Setter.Value>
                                </Setter>
                                <Setter Property="ItemTemplate">
                                    <Setter.Value>
                                        <DataTemplate>
                                            <view:HorizontalWvWObjectiveView DataContext="{Binding}" Visibility="{Binding IsVisible, Converter={StaticResource BoolToVisibility}}"/>
                                        </DataTemplate>
                                    </Setter.Value>
                                </Setter>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding UserSettings.IsTrackerHorizontal}" Value="True">
                                        <DataTrigger.Setters>
                                            <Setter Property="ItemTemplate">
                                                <Setter.Value>
                                                    <DataTemplate>
                                                        <view:VerticalWvWObjectiveView DataContext="{Binding}" Visibility="{Binding IsVisible, Converter={StaticResource BoolToVisibility}}"/>
                                                    </DataTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </DataTrigger.Setters>
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </ItemsControl.Style>
                    </ItemsControl>
                    <StackPanel.Style>
                        <Style TargetType="StackPanel">
                            <Setter Property="Orientation" Value="Vertical" />
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding UserSettings.IsTrackerHorizontal}" Value="True">
                                    <DataTrigger.Setters>
                                        <Setter Property="Orientation" Value="Horizontal" />
                                    </DataTrigger.Setters>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </StackPanel.Style>
                </StackPanel>
            </ScrollViewer>
        </Grid>

        <Grid Name="ResizeHeight" Grid.Row="2"
              Cursor="SizeNS"
              MouseLeftButtonDown="Resize_Init" MouseLeftButtonUp="Resize_End" MouseMove="Resizeing_Form"
              HorizontalAlignment="Left">

            <Rectangle HorizontalAlignment="Stretch"
                       Height="3"
                       Fill="#01FFA500">
            </Rectangle>

            <Rectangle VerticalAlignment="Bottom"
                       HorizontalAlignment="Stretch"
                       Height="1">
                <Rectangle.Fill>
                    <LinearGradientBrush>
                        <GradientStop Color="#FFFFA500" Offset="0.5"/>
                        <GradientStop Color="#00FFA500" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>

            <Grid.Style>
                <Style TargetType="Grid">
                    <Setter Property="Width" Value="188" />
                    <Setter Property="Visibility" Value="Visible" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding UserSettings.IsTrackerHorizontal}" Value="True">
                            <DataTrigger.Setters>
                                <Setter Property="Visibility" Value="Collapsed" />
                            </DataTrigger.Setters>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding UserSettings.AreTimeDistancesShown}" Value="False">
                            <DataTrigger.Setters>
                                <Setter Property="Width" Value="140" />
                            </DataTrigger.Setters>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Grid.Style>
        </Grid>

        <Grid Name="ResizeWidth" Grid.Row="0" Grid.RowSpan="3"
              Cursor="SizeWE"
              VerticalAlignment="Top"
              MouseLeftButtonDown="Resize_Init" MouseLeftButtonUp="Resize_End" MouseMove="Resizeing_Form">

            <Rectangle VerticalAlignment="Stretch"
                       HorizontalAlignment="Right"
                       Width="3"
                       Fill="#01FFA500">
            </Rectangle>

            <Rectangle VerticalAlignment="Stretch"
                       HorizontalAlignment="Right"
                       Width="1">
                <Rectangle.Fill>
                    <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                        <GradientStop Color="#00FFA500" Offset="0"/>
                        <GradientStop Color="#FFFFA500" Offset="0.5"/>
                        <GradientStop Color="#00FFA500" Offset="1"/>
                    </LinearGradientBrush>
                </Rectangle.Fill>
            </Rectangle>

            <Grid.Style>
                <Style TargetType="Grid">
                    <Setter Property="Height" Value="115" />
                    <Setter Property="Visibility" Value="Collapsed" />
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding UserSettings.IsTrackerHorizontal}" Value="True">
                            <DataTrigger.Setters>
                                <Setter Property="Visibility" Value="Visible" />
                            </DataTrigger.Setters>
                        </DataTrigger>
                        <DataTrigger Binding="{Binding UserSettings.AreTimeDistancesShown}" Value="False">
                            <DataTrigger.Setters>
                                <Setter Property="Height" Value="90" />
                            </DataTrigger.Setters>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Grid.Style>
        </Grid>

    </Grid>
</src:OverlayWindow>
